package com.atguigu.mall.mallproduct.service.impl;

import com.atguigu.common.es.SkuEsModel;
import com.atguigu.mall.mallproduct.feign.WareFeignService;
import com.atguigu.mall.mallproduct.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.mall.mallproduct.dao.PmsSpuInfoDao;
import com.atguigu.mall.mallproduct.entity.PmsSpuInfoEntity;
import com.atguigu.mall.mallproduct.service.PmsSpuInfoService;

@Service("pmsSpuInfoService")
public class PmsSpuInfoServiceImpl extends ServiceImpl<PmsSpuInfoDao, PmsSpuInfoEntity>
    implements PmsSpuInfoService {

  @Override
  public PageUtils queryPage(Map<String, Object> params) {
    IPage<PmsSpuInfoEntity> page =
        this.page(
            new Query<PmsSpuInfoEntity>().getPage(params), new QueryWrapper<PmsSpuInfoEntity>());
    return new PageUtils(page);
  }

  @Autowired PmsSpuInfoService pmsSpuInfoService;

  @Autowired WareFeignService wareFeignService;

  @Override
  public void up(Long spuId) {
    List<SkuEsModel> upProducts = new ArrayList<>();

    // 组装需要的数据
    SkuEsModel skuEsModel = new SkuEsModel();
    // 1.查出当前spuid对应的所有sku信息,品牌名称
    // 2.封装每个spu的信息
    // TODO 1.发送远程调用,库存系统查询是否有库存

    // TODO 2.热度评分 0
    // TODO 3.查询品牌的分类的名字信息
    // TODO 5.将数据发送给ES进行保存:mall-search

  }

  @Override
  public SkuItemVo skuItem(Long skuId) {
    SkuItemVo skuItemVo = new SkuItemVo();
    // 1.sku基本信息获取
    // 2.sku图片信息
    // 3.获取spu的销售属性组合
    // 4.获取spu的介绍
    // 5.获取spu的规格参数信息
    PmsSpuInfoDao dao = this.baseMapper;
    return null;
  }
}
